//
//  CenterScrollerViewSubView.m
//  JZRJAPPT
//
//  Created by mac on 16/5/8.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "CenterScrollerViewSubView.h"

@interface CenterScrollerViewSubView ()

@property (nonatomic, strong)UILabel *titleLabel;

@property (nonatomic , strong)UILabel *valueLabel;

@property (nonatomic , strong)UILabel *preLabel;

@property (nonatomic , strong)UILabel *topLabel;

@property (nonatomic , strong)UILabel *changLabel;

@property (nonatomic ,strong) UILabel *lastLable;

@end

@implementation CenterScrollerViewSubView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setLayoutViews];
    }
    return self;
}

- (void)setLayoutViews{
    self.backgroundColor = [UIColor whiteColor];
    
    __weak typeof(self) weakSelf = self;
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.text =@"asdadassda";
    _valueLabel = [[UILabel alloc] init];
    _valueLabel.font = [UIFont systemFontOfSize:15];
    
    _preLabel = [[UILabel alloc] init];
    _preLabel.font = [UIFont systemFontOfSize:15];
    
    _topLabel = [[UILabel alloc] init];
    _topLabel.font = [UIFont systemFontOfSize:15];
    
    _changLabel = [[UILabel alloc] init];
    _changLabel.layer.borderWidth = 2;
    
    _changLabel.layer.cornerRadius = 10;
    _lastLable = [[UILabel alloc]init];
     _lastLable.font = [UIFont systemFontOfSize:15];
    [self addSubview:_titleLabel];
    [self addSubview:_valueLabel];
    [self addSubview:_preLabel];
    [self addSubview:_topLabel];
    [self addSubview:_changLabel];
    [self addSubview:_lastLable];
   
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf).mas_offset(5);
        make.left.right.equalTo(weakSelf);
    }];
    
    [_valueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLabel.mas_bottom).mas_offset(3);
        make.left.right.equalTo(weakSelf);
        
    }];
    
    [_preLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_valueLabel.mas_bottom).mas_offset(3);
        make.right.equalTo(weakSelf.mas_centerX).mas_offset(-4);
    }];
    
    [_topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_valueLabel.mas_bottom).mas_offset(3);
        make.left.equalTo(weakSelf.mas_centerX).mas_offset(4);
    }];
    
    [_changLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_preLabel.mas_bottom).mas_offset(3);
        make.right.equalTo(weakSelf.mas_centerX).mas_offset(-4);
        make.width.equalTo(@30);
        
    }];
    [_lastLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_preLabel.mas_bottom).mas_offset(3);
        make.left.equalTo(weakSelf.mas_centerX).mas_offset(4);
        
    }];
    
    _titleLabel.textAlignment = NSTextAlignmentCenter;
    _valueLabel.textAlignment = NSTextAlignmentCenter;
    _preLabel.textAlignment = NSTextAlignmentRight;
    _topLabel.textAlignment = NSTextAlignmentLeft;
    _changLabel.textAlignment = NSTextAlignmentCenter;
    _lastLable.textAlignment =NSTextAlignmentCenter;
   
}

-(void)setMarkModel:(MarketModel *)markModel{
    NSLog(@"%@",markModel.Name);
    self.titleLabel.text = markModel.Name;
    self.valueLabel.text = [markModel.LastPrice stringValue];
    self.preLabel.text = [markModel.ChgPrice stringValue];
    self.topLabel.text = [NSString stringWithFormat:@"%.2f%@", [markModel.ChgRate floatValue] * 100,@"%"];
    self.changLabel.text = [markModel.FinalScore stringValue];
    self.lastLable.text = markModel.LHOpinion;
    if ([_lastLable.text isEqualToString:@"下跌"]) {
        _valueLabel.textColor = [UIColor greenColor];
        _preLabel.textColor = [UIColor greenColor];
        _topLabel.textColor = [UIColor greenColor];
        _changLabel.textColor = [UIColor greenColor];
        _lastLable.textColor = [UIColor greenColor];
        _changLabel.layer.borderColor = [UIColor greenColor].CGColor;
        
    }if ([_lastLable.text isEqualToString:@"上涨"]) {
        _lastLable.textColor = [UIColor redColor];
        _valueLabel.textColor = [UIColor redColor];
        _preLabel.textColor = [UIColor redColor];
        _topLabel.textColor = [UIColor redColor];
        _changLabel.textColor = [UIColor redColor];
        _lastLable.textColor = [UIColor redColor];
        _changLabel.layer.borderColor = [UIColor redColor].CGColor;
    }if ([_lastLable.text isEqualToString:@"横盘"]) {
        _lastLable.textColor = [UIColor yellowColor];
        _valueLabel.textColor = [UIColor yellowColor];
        _preLabel.textColor = [UIColor yellowColor];
        _topLabel.textColor = [UIColor yellowColor];
        _changLabel.textColor = [UIColor yellowColor];
        _lastLable.textColor = [UIColor yellowColor];
        _changLabel.layer.borderColor = [UIColor yellowColor].CGColor;
    }

    
}
@end
